/*
 * Copyright (c) 2007 centrevillage <centrevillage@gmail.com>
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
#ifndef  MIDIEXCEPTION_INC
#define  MIDIEXCEPTION_INC

#include <string>
#include <sstream>

namespace seq {

class SeqException : public std::exception {
public:
    SeqException() : msg_("SeqException") {
    }

    SeqException(const char* msg) : msg_(msg) {}
    SeqException(const std::string& msg) : msg_(msg) {}

    SeqException(const std::string& msg, const std::string& file, long line) {
        std::ostringstream ost;
        ost << "SeqException" << std::endl;
        ost << "    [" << msg << "]" << std::endl;
        ost << "    at " << file << "(" << line << ")";
        msg_ = ost.str();
    }

    virtual ~SeqException() {}
protected:
    std::string msg_;
public:
    virtual const char* what() const { return msg_.c_str(); }
};

class MidiException : public SeqException {
public:
    MidiException() {
        SeqException::SeqException("MidiException");
    }

    MidiException(const char* msg) : SeqException(msg) {}
    MidiException(const std::string& msg) : SeqException(msg) {}

    MidiException(const std::string& msg, const std::string& file, long line) {
        std::ostringstream ost;
        ost << "MidiException" << std::endl;
        ost << "    [" << msg << "]" << std::endl;
        ost << "    at " << file << "(" << line << ")";
        msg_ = ost.str();
    }

    virtual ~MidiException() {}
public:
    virtual const char* what() const { return msg_.c_str(); }
};

class ProjectLoadError : public SeqException {
public:
    ProjectLoadError() {
        SeqException::SeqException("ProjectLoadError");
    }

    ProjectLoadError(const char* msg) : SeqException(msg) {}
    ProjectLoadError(const std::string& msg) : SeqException(msg) {}

    ProjectLoadError(const std::string& msg, const std::string& file, long line) {
        std::ostringstream ost;
        ost << "ProjectLoadError" << std::endl;
        ost << "    [" << msg << "]" << std::endl;
        ost << "    at " << file << "(" << line << ")";
        msg_ = ost.str();
    }

    virtual ~ProjectLoadError() {}
public:

    virtual const char* what() const { return msg_.c_str(); }
};

class WaveException : public SeqException {
public:
    WaveException() {
        SeqException::SeqException("WaveException");
    }

    WaveException(const char* msg) : SeqException(msg) {}
    WaveException(const std::string& msg) : SeqException(msg) {}

    WaveException(const std::string& msg, const std::string& file, long line) {
        std::ostringstream ost;
        ost << "WaveException" << std::endl;
        ost << "    [" << msg << "]" << std::endl;
        ost << "    at " << file << "(" << line << ")";
        msg_ = ost.str();
    }

    virtual ~WaveException() {}
public:
    virtual const char* what() const { return msg_.c_str(); }
};


} // end of namespace seq

#endif   /* ----- #ifndef MIDIEXCEPTION_INC  ----- */
